﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PInitiatives.Models
{
    public partial class AcceptanceList
    {
        public AcceptanceList() { }

        public AcceptanceList(Guid code, int userId, string type, string attribute) 
        {
            this.Code = code;
            this.UserID = userId;
            this.Type = type;
            this.Attribute = attribute;
        }

        public Initiative GetInitative()
        {
            PInitiativesEntities db = new PInitiativesEntities();
            int initativeID = int.Parse(this.Attribute);
            if (this.Type == "Outlook")
                return db.Initiatives.SingleOrDefault(i => i.ID == initativeID);
            else
                return null;

        }
    }
}